RubyDevilYT / ƬɌ✯Team Rivality Script[Test Mode]

// ==UserScript==
// @name         ƬɌ✯Team Rivality Script[Test Mode]
// @namespace    http://tampermonkey.net/
// @version      1.0.9[Beta]
// @description  TeamRivality's Script [Test Mode]
// @author       RubyDevilYT
// @require      http://code.jquery.com/jquery-latest.js
// @require      https://cdn.jsdelivr.net/npm/@widgetbot/crate@3
// @match        https://agar.io/*
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        GM_addStyle
// @license      MIT
// ==/UserScript==
var $ = window.jQuery;


window.onload = function() {

//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    //NO ADS START
    $('#advertisement').remove();
    $('#mainui-promo').remove();
    $('#adsGameOver').remove();
    $('#mainui-ads').remove();
    $('#adsBottom').remove();
    //NO ADS END
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------





//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    //INJECT HTML START
var mainUI = document.querySelectorAll("[data-v-04522a78]")[6];
var HTMLelement = document.querySelector("body");

    $('#mainui-features').appendTo(mainUI);

    $('<div id="TRsettings" class="TR-settings">  <input type="button" id="TRsettingsbtn" class="TR-settings-btn">  <div id="TRoptionbox"></div>  </div>').appendTo(HTMLelement);
    const TRsettingsbtn = document.getElementById('TRsettingsbtn');
    const TRsettings = document.getElementById('TRsettings');
    TRsettingsbtn.addEventListener('click', (event) => {
        TRsettings.classList.toggle('TR-open')
    }, true);

    $('<div id="settings_titlebox" class="TR-title-box">  <h1 id="settings_title" style="margin: auto; align-self; color:white; font-weight:800; font-size:2em;">✯Settings✯</h1>  </div>').appendTo('#TRoptionbox');

    $(script_Recaptcha).appendTo('head');

    var MassEject_HTML = `<div id="MassEject_box" class="TRoption">  <input type="checkbox" id="Mass_Eject" class="TRinputbox"><label for="Mass_Eject" class="switch">Toggle</label>  <label id="Mass_Eject_label" class="TRlabel">Fast Mass Eject</label>  <span id="Mass_Eject_key" class="keybind"> W </span>  </div>`;
    $(MassEject_HTML).appendTo('#TRoptionbox');

    var Doublesplit_HTML = `<div id="Doublesplit_box" class="TRoption">  <input type="checkbox" id="Doublesplit" class="TRinputbox"><label for="Doublesplit" class="switch">Toggle</label>  <label id="Doublesplit_label" class="TRlabel">Doublesplit  </label>  <span id="Doublesplit_key" class="keybind"> D </span>  </div>`;
    $(Doublesplit_HTML).appendTo('#TRoptionbox');

    var Tricksplit_HTML = `<div id="Tricksplit_box" class="TRoption">  <input type="checkbox" id="Tricksplit" class="TRinputbox"><label for="Tricksplit" class="switch">Toggle</label>  <label id="Tricksplit_label" class="TRlabel">Tricksplit</label>  <span id="Tricksplit_key" class="keybind"> E </span>  </div>`;
    $(Tricksplit_HTML).appendTo('#TRoptionbox');

    var Freeze_Cell_HTML = `<div id="Freeze_Cell_box" class="TRoption">  <input type="checkbox" id="Freeze_Cell" class="TRinputbox"><label for="Freeze_Cell" class="switch">Toggle</label>  <label id="Freeze_Cell_label" class="TRlabel">Freeze Cell</label>  <span id="Freeze_Cell_key" class="keybind"> S </span>  </div>`;
    $(Freeze_Cell_HTML).appendTo('#TRoptionbox');

    var ShowMinimap_HTML = `<div id="Show_Minimap_box" class="TRoption">  <input type="checkbox" id="Show_Minimap" class="TRinputbox"><label for="Show_Minimap" class="switch">Toggle</label>  <label id="Show_Minimap_label" class="TRlabel">Show Minimap</label>  <span id="Show_Minimap_key" class="keybind"> M </span>  </div>`;
    $(ShowMinimap_HTML).appendTo('#TRoptionbox');

    var ShowPlayers_HTML = `<div id="Show_Players_box" class="TRoption">  <input type="checkbox" id="Show_Players" class="TRinputbox"><label for="Show_Players" class="switch">Toggle</label>  <label id="Show_Players_label" class="TRlabel">Show Players</label>  <span id="Show_Players_key" class="keybind"> P </span>  </div>`;
    $(ShowPlayers_HTML).appendTo('#TRoptionbox');


    var SaveButton_HTML = `<input type="button" id="SaveButton" class="TRoption TR-button" value="save ">`;
    $(SaveButton_HTML).appendTo('#TRoptionbox');



    var WidgetBot_script_html = ` <script src="https://cdn.jsdelivr.net/npm/@widgetbot/html-embed"></script> `;
    var WidgetBot_html = ` <widgetbot id="chatbox" server="704129977146409090" channel="830852526207270963" style="height:100%;width:100%;"></widgetbot> `;
    $(WidgetBot_script_html).appendTo('head');
    $(WidgetBot_html).appendTo('#mainui-promo');
    //INJECT HTML END
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------





//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    //LOAD SETTINGS START
    const mass_eject = document.getElementById('Mass_Eject');
    const doublesplit = document.getElementById('Doublesplit');
    const tricksplit = document.getElementById('Tricksplit');
    const freeze_cell = document.getElementById('Freeze_Cell');
    const show_minimap = document.getElementById('Show_Minimap');
    const show_players = document.getElementById('Show_Players');

        if(getCookie("mass_eject") == 'off') {mass_eject.checked = false; console.log('Loaded => mass_eject = off')} else if(getCookie("mass_eject") == 'on') {mass_eject.checked = true; console.log('Loaded => mass_eject = on')}
        if(getCookie("doublesplit") == 'off') {doublesplit.checked = false; console.log('Loaded => doublesplit = off')} else if(getCookie("doublesplit") == 'on') {doublesplit.checked = true; console.log('Loaded => doublesplit = on')}
        if(getCookie("tricksplit") == 'off') {tricksplit.checked = false; console.log('Loaded => tricksplit = off')} else if(getCookie("tricksplit") == 'on') {tricksplit.checked = true; console.log('Loaded => tricksplit = on')}
        if(getCookie("freeze_cell") == 'off') {freeze_cell.checked = false; console.log('Loaded => freeze_cell = off')} else if(getCookie("freeze_cell") == 'on') {freeze_cell.checked = true; console.log('Loaded => freeze_cell = on')}
        if(getCookie("show_minimap") == 'off') {show_minimap.checked = false; console.log('Loaded => show_minimap = off')} else if(getCookie("show_minimap") == 'on') {show_minimap.checked = true; console.log('Loaded => show_minimap = on'); core.setMinimap(1)}
        if(getCookie("show_players") == 'off') {show_players.checked = false; console.log('Loaded => show_players = off')} else if(getCookie("show_players") == 'on') {show_players.checked = true; console.log('Loaded => show_players = on'); core.playersMinimap(1)}

    var SaveButton = document.getElementById('SaveButton');
    SaveButton.addEventListener('click', saveSettings)
    //LOAD SETTINGS END
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------





/*------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
    //FORCE CLAN TAG START
    var _username = document.getElementById('nick');

    $('#nick').keydown(function(e) {
        var oldvalue = $(this).val();
        var field = this;
        setTimeout(function () {
            if(field.value.indexOf('ƬɌ✯') !== 0 && oldvalue.indexOf('ƬɌ✯') >= 0) {
                $(field).val(oldvalue);
            }
            else if ( field.value.indexOf('ƬɌ✯') !== 0 && !(oldvalue.indexOf('ƬɌ✯') >= 0) ) {
                $(field).val('ƬɌ✯'+oldvalue);
            }
        }, 1);
    });
    //FORCE CLAN TAG END
/*------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/



}; //onload funciton end



//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    /*MACRO START*/

window.addEventListener('keydown', keydown);
window.addEventListener('keyup', keyup);


var EjectDown = false;
var speed = 25; /*in ms*/

function keydown(event) {
    var mass_eject = $('input#Mass_Eject:checked').length;
    var doublesplit = $('input#Doublesplit:checked').length;
    var tricksplit = $('input#Tricksplit:checked').length;
    var freeze_cell = $('input#Freeze_Cell:checked').length;
    var show_minimap = document.getElementById('Show_Minimap');
    var show_players = document.getElementById('Show_Players');

    if (event.keyCode == 87 && mass_eject==1) { // key W
        EjectDown = true;
        setTimeout(eject, speed);
    }
    if (event.keyCode == 68 && doublesplit==1) { // key D
        split();
        setTimeout(split, speed);
    }
    if (event.keyCode == 69 && tricksplit==1) { // key E
        split();
        setTimeout(split, speed);
        setTimeout(split, speed*2);
        setTimeout(split, speed*3);
    }
    if (event.keyCode == 83 && freeze_cell==1) { // key S
        X = window.innerWidth/2;
        Y = window.innerHeight/2;
        $("canvas").trigger($.Event("mousemove", {clientX: X, clientY: Y}));
    }
    if(event.keyCode == 77) { // key M
        show_minimap.checked = show_minimap.checked ? false : true;
        if(show_minimap.checked == true) { core.setMinimap(1) }
        else { core.setMinimap(0) }
    }
    if(event.keyCode == 80) { // key P
        show_players.checked = show_players.checked ? false : true;
        if(show_players.checked == true) { core.playersMinimap(1) }
        else { core.setMinimap(0) }
    }
};

function keyup(event) {
    if (event.keyCode == 87) { // key W
        EjectDown = false;
    }
};

function eject() {
    if (EjectDown) {
        $("body").trigger($.Event("keydown", { keyCode: 87})); /*key Space */
        $("body").trigger($.Event("keyup", { keyCode: 87})); /*jquery is required for split to work*/
        setTimeout(eject, speed);
    }
};

function split() {
    $("body").trigger($.Event("keydown", { keyCode: 32})); /*key Space */
    $("body").trigger($.Event("keyup", { keyCode: 32})); /*jquery is required for split to work*/
};
    //MACRO END
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------





//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//FPS COUNTER START

$(document).ready(function(){

    $("body").append('<div id="fpsbg" style="position:absolute; bottom:3em; left:1em; background-color:rgba(0,0,0,0.3); color:#ffffff;  padding:5px;border-radius:5px;">⏱️ FPS: <span id="fps"></span></div>');

const fps = {
    sampleSize : 60,
    value : 0,
    _sample_ : [],
    _index_ : 0,
    _lastTick_: false,
    tick : function(){
        // if is first tick, just set tick timestamp and return
        if( !this._lastTick_ ){
            this._lastTick_ = performance.now();
            return 0;
        }
        // calculate necessary values to obtain current tick FPS
        let now = performance.now();
        let delta = (now - this._lastTick_)/1000;
        let fps = 1/delta;
        // add to fps samples, current tick fps value
        this._sample_[ this._index_ ] = Math.round(fps);

        // iterate samples to obtain the average
        let average = 0;
        for(var i=0; i<this._sample_.length; i++) average += this._sample_[ i ];

        average = Math.round( average / this._sample_.length);

        // set new FPS
        this.value = average;
        // store current timestamp
        this._lastTick_ = now;
        // increase sample index counter, and reset it
        // to 0 if exceded maximum sampleSize limit
        this._index_++;
        if( this._index_ === this.sampleSize) this._index_ = 0;
        return this.value;
    }
}

function loop(){
    let fpsValue = fps.tick();
    document.getElementById('fps').innerHTML = fpsValue;
    requestAnimationFrame( loop );
}
// set FPS calulation based in the last 120 loop cicles
fps.sampleSize = 120;
// start loop
loop();

});

//FPS COUNTER END
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------





//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    //SAVE SETTINGS START
function saveSettings(param) {

    var mass_eject = $('input#Mass_Eject:checked').length;
    var doublesplit = $('input#Doublesplit:checked').length;
    var tricksplit = $('input#Tricksplit:checked').length;
    var freeze_cell = $('input#Freeze_Cell:checked').length;
    var show_minimap = $('input#Show_Minimap:checked').length;
    var show_players = $('input#Show_Players:checked').length;

    if(mass_eject == 1) {setCookie("mass_eject","on")} else {setCookie("mass_eject","off")}
    if(doublesplit == 1) {setCookie("doublesplit","on")} else {setCookie("doublesplit","off")}
    if(tricksplit == 1) {setCookie("tricksplit","on")} else {setCookie("tricksplit","off")}
    if(freeze_cell == 1) {setCookie("freeze_cell","on")} else {setCookie("freeze_cell","off")}
    if(show_minimap == 1) {setCookie("show_minimap","on")} else {setCookie("show_minimap","off")}
    if(show_players == 1) {setCookie("show_players","on")} else {setCookie("show_players","off")}

    console.log('settings has been set!')//document.cookie = "mass_eject=off"
}
    //SAVE SETTINGS END
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------





//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    /*COOCKIES FUNCTION START*/

function setCookie(cname,cvalue) {
  document.cookie = cname + "=" + cvalue + ";";
}

function getCookie(cname) {
  var name = cname + "=";
  var decodedCookie = decodeURIComponent(document.cookie);
  var ca = decodedCookie.split(';');
  for(var i = 0; i < ca.length; i++) {
    var c = ca[i];
    while (c.charAt(0) == ' ') {
      c = c.substring(1);
    }
    if (c.indexOf(name) == 0) {
      return c.substring(name.length, c.length);
    }
  }
  return "";
}
    /*COOKIES FUNCTION END*/
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------





GM_addStyle ( `

    div { color: white; }

    .btn {
        background-color:   #ff00ff;
    }
    .text-muted {
        display:none;
    }

    .TR-title-box {
        margin-top:         auto;
        margin-right:       auto;
        margin-bottom:      1em;
        margin-left:        auto;
        height:             2em;
        display:            flex;
        align-items:        center;
    }
    .TR-settings {
        z-index:            99999;
        height:             3.5em;
        width:              3.5em;
        display:            block;
        position:           fixed;
        top:                0.5em;
        left:               0.5em;
        overflow:           hidden;
        transition-property: all;
        transition-duration: 1s;
    }
    .TR-settings:hover {
        height:            100%;
        width:             21em;
    }
    .TR-settings-btn {
        width:             3.5em;
        height:            3.5em;
        display:           inline-block;
        border:            none;
        border-radius:     0.4em;
        outline:           none;
        background:        url('https://i.imgur.com/Gq4ByRv.png');
        background-size:   100%;
    }
    .TR-button {
        background-color:  #6ff542 !important;
        justify-content:   center !important;
        font-family:       Helvetica, Arial, sans-serif;
        font-weight:       bold;
    }
    .TR-button:focus {
        outline:           none;
    }
    .TR-open {
        height:            100%;
        width:             21em;
    }
    #TRoptionbox {
        height:            min-content;
        width:             17.5em;
        display:           inline-block;
        position:          absolute;
        background-color:  #17181B;
        border-radius:     1.5em;
        padding-bottom:    0.5em;
    }
    .TRoption {
        height:            2em;
        width:             85%;
        position:          relative;
        background-color:  #202124;
        border-radius:     0.8em;
        margin:            auto;
        margin-top:        0.25em;
        margin-bottom:     0.25em;
        display:           flex;
        align-items:       center;
    }
    .keybind {
        background-color:  #34a4eb;
        color:             #ffffff;
        border-radius:     0.7em;
        height:            1.5em;
        width:             3em;
        margin-right:      0.3em;
        display:           flex;
        align-items:       center;
        justify-content:   center;
    }
    input.TRinputbox{
        margin-left:   0.3em;
		height:        0;
		width:         0;
		visibility:    hidden;
    }
    input.TRinputbox:checked + label.switch {
		background: #bada55;
	}
	input.TRinputbox:checked + label.switch:after {
		left: calc(100% - 0.05em);
		transform: translateX(-100%);
	}
    label.switch {
    	margin-right: 0.5em;
		cursor: pointer;
		text-indent: -9999px;
		width: 3em;
		height: 1.5em;
		background: grey;
		display: block;
		border-radius: 1em;
		position: relative;
	}
	label.switch:after {
		content: '';
		position: absolute;
		top: 0.1em;
		left: 0.1em;
		width: 1.3em;
		height: 1.3em;
		background: #ffffff;
		border-radius: 0.9em;
		transition: 0.3s;
	}



    .TRlabel {
        color:            white;
        position:         relative;
        height:           80%;
        width:            80%;
        margin-left:      auto;
        margin-right:     auto;
        display:          flex;
        align-items:      center;
    }


    #settingsButton {
        background: none;
    }
    #nick {
        color: black;
    }
    div.bubble[data-v-0733aa78] {
        display: none;
    }
    #socialButtons {
        display: none;
    }

    #mainui-app {

    }
    #mainui-offers, #mainui-play, #mainui-user, #mainui-features, #mainui-modes, #mainui-party, #blocker {
        background: url('https://images5.alphacoders.com/101/1010881.jpg') no-repeat center center fixed !important;
        -webkit-background-size: cover !important;
        -moz-background-size: cover !important;
        -o-background-size: cover !important;
        background-size: cover !important;
    }

    .currency-container {
        background-color: white;
    }
    .progress-bar-container {
        background-color: white;
    }
    div.options[data-v-0b8695e7] {
        background-color: #17181B;
        padding: 15px;
        font-size: 16px;
        color: #7d7d7d;
        display: flex;
        flex-wrap: wrap;
        justify-content: flex-start;
        margin-top: 10px;
    }
    div.dialog[data-v-0b8695e7] {
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        border-radius: 10px;
        background-color: #17181B;
        width: 360px;
        padding: 15px;
        text-align: left;
    }
    .party-text[data-v-3152cd5c] { color: white; };
    .text-muted { display: none; };

` );





var script_Recaptcha = `<script src="https://legendmod.ml/ogario/captcha.js"></script>`;